import BusinessConstant from "@/constant/BusinessConstant";
import request from "../request";
import { RentBillEntity } from "@/entities/RentBillEntity";

// 路径前缀
const PREFIX = BusinessConstant.ROOT_SERVER + "/rent_bill";

export default class RentBillApi {
  static addRentBill(rentBillObj: RentBillEntity.IAddRentBillReq) {
    return request({
      method: "POST",
      url: PREFIX,
      data: rentBillObj,
    });
  }

  static getRentBillByLandlordId(landlordId: number) {
    return request({
      method: "GET",
      url: `${PREFIX}/landlord_id?landlordId=${landlordId}`,
    });
  }

  static getRentBillByTenantId(tenantId: number) {
    return request({
      method: "GET",
      url: `${PREFIX}/tenant_id?tenantId=${tenantId}`,
    });
  }

  static getRentBillByBillDate(billDateObj: RentBillEntity.IRentBillDateReq) {
    const { houseId, tenantId, landlordId, billDate } = billDateObj;
    return request({
      method: "GET",
      url: `${PREFIX}/bill_date?houseId=${houseId}&tenantId=${tenantId}&landlordId=${landlordId}&billDate=${billDate}`,
    });
  }
}
